<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%> 
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="css_js/jquery/jquery-1.3.2.min.js"></script>
<link href="css_js/index.css" rel="stylesheet" type="text/css"></link>
<link href="css_js/general.css" rel="stylesheet" type="text/css"></link>
<script src="css_js/popup.js" type="text/javascript"></script>
<link href="css_js/calendar.css" rel="stylesheet" type="text/css"></link>
<script src="css_js/cal.js" type="text/javascript"></script>

<title>添加用户</title>
<script type="text/javascript">

jQuery(document).ready(function () {
	$('#next_touch_date').simpleDatepicker({ startdate: 1960, enddate: 2060 });
	$('#time1').simpleDatepicker({ startdate: 1960, enddate: 2060 });
	$('#time2').simpleDatepicker({ startdate: 1960, enddate: 2060 });
	//判断状态显示时间颜色
	if($('#next_touch_date').val()!="点击显示时间列表"){
		$('#next_touch_date').removeClass("addTimeInit");
		$('#next_touch_date').addClass("addTimeClick");
	}
	if($('#time1').val()!="点击显示时间列表"){
		$('#time1').removeClass("addTimeInit");
		$('#time1').addClass("addTimeClick");
	}
	if($('#time2').val()!="点击显示时间列表"){
		$('#time2').removeClass("addTimeInit");
		$('#time2').addClass("addTimeClick");
	}
});
</script>
<script type="text/javascript">
function submitForm(){
	if(checkEmpty()){
		document.getElementById("addCompanyForm").submit();
	}
}
function checkEmpty(){
	if($("#code").val() == ""){
		$("#errorInfo").text("客户编码不能为空!");
		return false;
	}
	if($("#name").val() == ""){
		$("#errorInfo").text("客户名称不能为空!");
		return false;
	}
	return true;
}
function getCityList(){
	//取得省份
	var province_str = $("#province_id").val();
	//将省份进行escape
	var queryString = {"id":province_str};

	//通过ajax方式传递数据
	$.ajax({	
		type:"post",
		url:"getCities.action",
		data:queryString,
		dataType:"json",
		success: function(msg) {
            $("#city_id").html("");
            var str = "<option value=1>---</option>";
            for(var i = 0; i < msg.SCities.length;i++){
            	//alert(msg.SCities[i].name);
            	str+="<option value="+msg.SCities[i].id+">"+msg.SCities[i].name+"</option>";
            }
            $("#city_id").html(str);
        }
	});
}

function getPyCode()
{
	var name = $("#name").val();

	if( name != "")
	{
		queryString = { name : name };
		$.ajax({	
			type:"post",
			url:"getPyCode.action",
			data:queryString,
			dataType:"json",
			success: function(msg) {
				$("#pycode").val(msg.name);
	        }
		});
	}
}

$(function(){
	var selects = ["customer_grade","region","source","trade","company_size","company_size","quality","company_dealin","company_choice1","company_choice2","company_choice3","company_choice4"];
	for(var i = 0; i < selects.length; i++){
		if($("#edit_id").val() != ""){
			initSelect(selects[i]);
		}
	}
});
</script>
</head>
<body STYLE='OVERFLOW:SCROLL;OVERFLOW-X:HIDDEN'>
 <form name="form1" method="post" id="addCompanyForm" action="addCompany.action">
<table width="99%" border="0" cellspacing="0" cellpadding="0" id="index_main_table">
              <tr>
                <td height="26" width="100%"> <span style="color:#002450; font-size:13px; font-weight:bold;">　客户--新建</span></td>
              </tr>
            </table>
			
			<table width="99%" border="0" cellspacing="0" cellpadding="0" id="index_content">
              <tr>
                <td height="12"></td>
              </tr>
              <tr>
                <td valign="middle" ><img src="image/s10.gif" width="58" height="22" style="cursor:pointer;" onclick="submitForm();"><img src="image/s9.gif" width="116" height="22"><img src="image/s8.gif" width="59" height="22"></td>
              </tr>
               <tr>
                <td id="errorInfo" style="font-size:12;color:ff0000;">
                	<s:actionmessage/>
                </td>
              </tr>
              <tr>
                <td valign="middle" ><table width="100%" border="0" cellspacing="0" cellpadding="0" id="index_main_div1">
                  <tr>
                    <td height="21" valign="top" background="image/index_main_div_titleBg.gif"><img style="margin-left:5px;" src="image/index_main_div_left.gif" width="6" height="2" align="absmiddle">&nbsp;<span style="font-weight:bold;font-size:12px;">基本信息</span></td>
                  </tr>
                  <tr>
                    <td height="56" align="left" valign="top" bgcolor="#f7fbfc">
                   
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" id="selectTable">
                          <tr>
                            <td width="10%">客户编码:</td>
                            <td width="41%"><input type="text" name="company.code" class="addCText" value="${todayStr}" id="code"></td>
                            <td width="10%" align="left">客户名称:</td>
                            <td width="42%"><input type="text" name="company.name" class="addCText" id="name" onkeyup="getPyCode();" value="%{#company.name}"></td>
                            <td width="0%">&nbsp;</td>
                          </tr>
                          <tr>
                            <td>拼音码:</td>
                            <td><input type="text" name="company.pycode" class="addCText" id="pycode"></td>
                            <td align="left">客户等级:</td>
                            <td><select name="company.grade" class="addCText" id="customer_grade">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 9">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                              <img src="image/s11.gif" onclick="loadPopup('customer_grade')"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>区域名称:</td>
                            <td>
							<select name="company.regionName" class="addCText" id="region">
							   <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 56">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
							<img src="image/s11.gif" onclick="loadPopup('region')">  </td>
                            <td align="left">客户来源:</td>
                            <td><select name="company.source" class="addCText" id="source">
                              <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 6">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                              
                            </select>
                              <img src="image/s11.gif" onclick="loadPopup('source')"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>所属行业:</td>
                            <td><select name="company.trade" class="addCText" id="trade">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 5">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                              <img src="image/s11.gif" onclick="loadPopup('trade')"></td>
                            <td align="left">公司规模:</td>
                            <td><select name="company.scale" class="addCText" id="company_size">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 61">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                               <img src="image/s11.gif" onclick="loadPopup('company_size')"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>传真:</td>
                            <td><input type="text" name="company.fax" class="addCText"></td>
                            <td align="left">邮政编码:</td>
                            <td><input type="text" name="company.postcode" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>省份:</td>
                            <td><select name="company.province" class="addCText" onchange="getCityList();" id="province_id">
                               <option value="">---</option>
                              <s:iterator value="#request.sProvinceList" id="sprovice">
                              		 <option value="${sprovice.id}">${sprovice.name}</option>
                              </s:iterator>
                            </select>
                              <img src="image/s11.gif"></td>
                            <td align="left">城市:</td>
                            <td><select name="company.city" class="addCText" id="city_id">
                              <option value="1">---</option>
                            </select>
                              <img src="image/s11.gif"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>联系地址:</td>
                            <td colspan="4"><input type="text" name="company.address" class="addCText1"></td>
                            </tr>
                          <tr>
                            <td>电子邮件:</td>
                            <td><input type="text" name="company.email" class="addCText"></td>
                            <td align="left">公司网址:</td>
                            <td><input type="text" name="company.web" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>电话一:</td>
                            <td><input type="text" name="company.tel1" class="addCText"></td>
                            <td align="left">电话二:</td>
                            <td><input type="text" name="company.tel2" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>手机:</td>
                            <td><input type="text" name="company.mobile" class="addCText"></td>
                            <td align="left">事实客户:</td>
                            <td><input type="radio" name="company.buyFlag" value="radiobutton">
                              是
                                <input type="radio" name="company.buyFlag" type="radio" value="radiobutton" checked="checked">
                            否</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td>下次联系时间:</td>
                            <td><input type="text" name="company.nextTouchDate" class="addTimeInit" id="next_touch_date" readonly="readonly" value="点击选择时间">
                            	</td>
                            <td align="left">客户性质:</td>
                            <td><select name="company.quality" class="addCText" id="quality">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 46">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                              <img src="image/s11.gif" onclick="loadPopup('quality')"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>备注</td>
                            <td colspan="3"><textarea name="company.remark" class="addCText2"></textarea></td>
                            <td>&nbsp;</td>
                            </tr>
                        </table>
                        
                    </td>
                  </tr>
                </table>
				
				<table width="100%" border="0" cellspacing="0" cellpadding="0" id="index_main_div1">
                  <tr>
                    <td height="21" valign="top" background="image/index_main_div_titleBg.gif"><img style="margin-left:5px;" src="image/index_main_div_left.gif" width="6" height="2" align="absmiddle">&nbsp;<span style="font-weight:bold;font-size:12px;">企业信息</span></td>
                  </tr>
                  <tr>
                    <td height="56" align="left" valign="top" bgcolor="#f7fbfc">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" id="selectTable">
                          <tr>
                            <td width="7%">经营范围:</td>
                            <td width="42%">
                            <select name="company.dealing" class="addCText" id="company_dealin">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 62">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                              <img src="image/s11.gif" onclick="loadPopup('company_dealin')"></td>
                            <td width="9%" align="left">企业性质:</td>
                            <td width="40%"><input type="text" name="company.kind" class="addCText"></td>
                            <td width="2%">&nbsp;</td>
                          </tr>
                          <tr>
                            <td>法人代表:</td>
                            <td><input type="text" name="company.legalPerson" class="addCText"></td>
                            <td align="left">注册资金:</td>
                            <td><input type="text" name="company.registerMoney" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>开户银行:</td>
                            <td><input type="text" name="company.bank" class="addCText"></td>
                            <td align="left">银行账户:</td>
                            <td><input type="text" name="company.account" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>公司税号:</td>
                            <td><input type="text" name="company.taxCode" class="addCText"></td>
                            <td align="left"></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                  </tr>
                </table>
				
				<table width="100%" border="0" cellspacing="0" cellpadding="0" id="index_main_div1">
                  <tr>
                    <td height="21" valign="top" background="image/index_main_div_titleBg.gif"><img style="margin-left:5px;" src="image/index_main_div_left.gif" width="6" height="2" align="absmiddle">&nbsp;<span style="font-weight:bold;font-size:12px;">自定义信息</span></td>
                  </tr>
                  <tr>
                    <td height="56" align="left" valign="top" bgcolor="#f7fbfc">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" id="selectTable">
                          <tr>
                            <td width="66">客户需求1:</td>
                            <td><input type="text" name="company.custom1" class="addCText"></td>
                            <td width="66" align="left">客户需求2:</td>
                            <td width="40%"><input type="text" name="company.custom2" class="addCText"></td>
                            <td width="1">&nbsp;</td>
                            </tr>
                          <tr>
                            <td>客户需求3:</td>
                            <td><input type="text" name="company.custom3" class="addCText"></td>
                            <td align="left">客户需求4:</td>
                            <td><input type="text" name="company.custom4" class="addCText"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>自定选项1:</td>
                            <td><select name="company.choice1" class="addCText" id="company_choice1">
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 15">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                            <img src="image/s11.gif" onclick="loadPopup('company_choice1')"></td>
                            <td align="left">自定选项2:</td>
                            <td><select name="company.choice2" class="addCText" id="company_choice2" >
                               <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 17">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                            <img src="image/s11.gif" onclick="loadPopup('company_choice2')" ></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>自定选项3:</td>
                            <td><select name="company.choice3" class="addCText" id="company_choice3" >
                                 <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 17">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                            <img src="image/s11.gif"  onclick="loadPopup('company_choice3')" ></td>
                            <td align="left">自定选项4</td>
                            <td><select name="company.choice4" class="addCText" id="company_choice4">
                                 <option value="">---</option>
                              <s:iterator value="#request.sDictionaryDetailList" id="sdDetail">
                              		<s:if test="#sdDetail.SDictionaryClass.id == 18">
                              		 <option value="${sdDetail.value}">${sdDetail.value}</option>
                              		 </s:if>
                              </s:iterator>
                            </select>
                            <img src="image/s11.gif" onclick="loadPopup('company_choice4')"  ></td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td>自定时间1:</td>
                            <td><input type="text" name="company.time1" id="time1" class="addTimeInit" readonly="readonly" value="点击选择时间">
                              </td>
                            <td align="left">自定时间2:</td>
                            <td><input type="text" name="company.time2" id="time2" class="addTimeInit" readonly="readonly" value="点击选择时间">
                             </td>
                            <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                  </tr>
                </table>
				
				
				<table width="100%" border="0" cellspacing="0" cellpadding="0" id="index_main_div1">
                  <tr>
                    <td height="21" valign="top" background="image/index_main_div_titleBg.gif"><img style="margin-left:5px;" src="image/index_main_div_left.gif" width="6" height="2" align="absmiddle">&nbsp;<span style="font-weight:bold;font-size:12px;">其他信息</span></td>
                  </tr>
                  <tr>
                    <td height="56" align="left" valign="top" bgcolor="#f7fbfc">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" id="selectTable">
                          <tr>
                            <td width="7%">创建人:</td>
                            <td width="42%"><input type="text" name="company.creater" class="addCText" readOnly="true" value="${user.username}">
                            </td>
                            <td width="9%" align="left">创建日期:</td>
                            <td width="40%"><input type="text" name="company.createTime" class="addCText" readOnly="true" value="${c_time}"></td>
                            <td width="2%">&nbsp;</td>
                            </tr>
                          <tr>
                            <td>修改人:</td>
                            <td><input type="text" name="company.updater" class="addCText" readOnly="true" value="${user.username}"></td>
                            <td align="left">修改日期:</td>
                            <td><input type="text" name="company.updateTime" class="addCText" readOnly="true"  value="${c_time}"></td>
                            <td>&nbsp;</td>
                            </tr>
                          <tr>
                            <td>所属人:</td>
                            <td><input type="text" name="company.ownerUsr" class="addCText" readonly="readonly"></td>
                            <td align="left">&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                  </tr>
                </table>
				</td>
              </tr>
			   <tr>
                <td valign="middle" >&nbsp;</td>
              </tr>
			   <tr>
                <td valign="middle" ><img src="image/s10.gif" width="58" height="22"><img src="image/s9.gif" width="116" height="22"><img src="image/s8.gif" width="59" height="22"></td>
              </tr>
			  <tr>
                <td valign="middle" >&nbsp;</td>
              </tr>
            </table>
</form>
<div id="popupContact">
	<a id="popupContactClose">x</a>
	<h1>标题</h1>
	<p id="contactArea">
		这里是正文	</p>
</div>
<div id="backgroundPopup"></div>
</body>
</html>
